package com.ssy.lingxi.enhance.controller.supplier;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.enhance.constant.RoleTypeEnum;
import com.ssy.lingxi.enhance.model.dto.AddProduceNoticeOrderDTO;
import com.ssy.lingxi.enhance.model.dto.CommonIdDTO;
import com.ssy.lingxi.enhance.model.dto.CommonIdListDTO;
import com.ssy.lingxi.enhance.model.dto.UpdateProduceNoticeOrderDTO;
import com.ssy.lingxi.enhance.model.qo.ProduceNoticeOrderQO;
import com.ssy.lingxi.enhance.model.vo.ProduceNoticeOrderDetailsVO;
import com.ssy.lingxi.enhance.model.vo.ProduceNoticeOrderListVO;
import com.ssy.lingxi.enhance.service.common.CommonService;
import com.ssy.lingxi.enhance.service.supplier.SupplierToBeAddService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @menu 加工能力 - 指派生产通知单(供应商) - 待新增生产通知单
 * @author fhj
 * @version 2.0.0
 * @date 2020/10/20
 */
@Api(tags = "加工能力 - 指派生产通知单(供应商) - 待新增生产通知单")
@RestController
@RequestMapping("/enhance/supplier/toBeAdd")
public class SupplierToBeAddController extends BaseController {

    @Resource
    private SupplierToBeAddService toBeAddService;
    @Resource
    private CommonService commonService;

    @ApiOperation(value = "新增")
    @PostMapping(value = "/add")
    public Wrapper<Void> add(@RequestBody @Valid AddProduceNoticeOrderDTO dto) {
        return toBeAddService.add(dto, getSysUser());
    }

    @ApiOperation(value = "修改")
    @PostMapping(value = "/update")
    public Wrapper<Void> update(@RequestBody @Valid UpdateProduceNoticeOrderDTO dto) {
        return toBeAddService.update(dto, getSysUser());
    }

    @ApiOperation(value = "列表")
    @GetMapping(value = "/list")
    public Wrapper<PageData<ProduceNoticeOrderListVO>> list(@Valid ProduceNoticeOrderQO qo) {
        return toBeAddService.list(qo, getSysUser());
    }

    @ApiOperation(value = "详情")
    @GetMapping(value = "/details")
    public Wrapper<ProduceNoticeOrderDetailsVO> details(@Valid CommonIdDTO dto) {
        return commonService.details(dto.getId(), RoleTypeEnum.SUPPLIER.getCode(), getSysUser());
    }

    @ApiOperation(value = "删除")
    @PostMapping(value = "/delete")
    public Wrapper<Void> delete(@RequestBody @Valid CommonIdDTO dto) {
        return toBeAddService.delete(dto, getSysUser());
    }

    @ApiOperation(value = "批量删除")
    @PostMapping(value = "/batchDelete")
    public Wrapper<Void> batchDelete(@RequestBody @Valid CommonIdListDTO dto) {
        return toBeAddService.batchDelete(dto, getSysUser());
    }

    @ApiOperation(value = "提交审核")
    @PostMapping(value = "/submitExam")
    public Wrapper<Void> submitExam(@RequestBody @Valid CommonIdDTO dto) {
        return toBeAddService.submitExam(dto, getSysUser());
    }

    @ApiOperation(value = "批量提交审核")
    @PostMapping(value = "/batchSubmitExam")
    public Wrapper<Void> batchSubmitExam(@RequestBody @Valid CommonIdListDTO dto) {
        return toBeAddService.batchSubmitExam(dto, getSysUser());
    }
}
